﻿using Basic.FormGatewaryModular.Interface;
using Basic.FormRemoteModel.QueryTable.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Api
{
    [ApiRouteName("/form/query/table/{name}")]
    internal class PhyQueryTableApi : ApiController
    {
        private readonly IPhyQueryTableService _Service;

        public PhyQueryTableApi ( IPhyQueryTableService service )
        {
            this._Service = service;
        }

        public long Add ( PhyQueryTableAdd add )
        {
            return this._Service.Add(add);
        }

        public void Delete ( [NumValidate("form.query.table.id.error", 1)] long id )
        {
            this._Service.Delete(id);
        }

        public PhyQueryTableData Get ( [NumValidate("form.query.table.id.error", 1)] long id )
        {
            return this._Service.Get(id);
        }

        public PhyQueryCol[] GetCols ( [NumValidate("form.query.table.id.error", 1)] long id )
        {
            return this._Service.GetCols(id);
        }

        public PhyQueryTableBody[] Gets ( [NumValidate("form.id.error", 1)] long formId, bool isHidden )
        {
            return this._Service.Gets(formId, isHidden);
        }

        public bool Set ( LongParam<PhyQueryTableSet> data )
        {
            return this._Service.Set(data.Id, data.Value);
        }
    }
}
